<!DOCTYPE html>
<html>
<head>
	<title>test</title>
</head>
<body>
	<header style="padding: 5px">
		<h2>jwt调用包装</h2>
	</header>
	<div>获取一个jwt</div>
	<div>
		<button onclick="jwtUtil.getJwt()">获取jwt</button>
		<p id="getJwt"></p>
	</div>
	<div class="form">

		<button onclick="jwtUtil.effect()">验证jwt</button>
		<p id="effectJwt"></p>
	</div>

	<script src="/component/jquery.min.js"></script>
	<script type="text/javascript">
		
		var jwtUtil = {};
		jwtUtil.access_token= '';//权限token
		jwtUtil.refresh_token= '';//更新用的token
		//登录获取access_token refresh_token
		jwtUtil.login = function(){

		}
		jwtUtil.getJwt = function(){
			//获取一个jwt
			$.post('/jwttest/getjwt',{},function(res){
				jwtUtil.access_token = res;
				$('#getJwt').html(res);
			})
		}
		//有效检查
		jwtUtil.effect = function(){
			console.log(jwtUtil.access_token)
			$.post('/jwttest/effect',{"token":jwtUtil.access_token},function(res){
				
				$('#effectJwt').html(res);
			})
		}
		//刷新access token
		jwtUtil.refresh = function(){

		}
		jwtUtil.post = function(){
			var data = $('#form').serialize();
			$.post('/validatex/post',data,function(res){
				console.log(res);
			})
		}
	</script>
</body>
</html>